/**
 * Created by beck on 2015/7/6.
 */
$(document).ready(function(){

	 if($mtype!="member")
		{
		 	//$(".backlefticon").css("display","block");
		 	//$("#back").click(function(){
		 		//window.location='login.html?groupid='+$groupid+"&islogin=0";
		        //});
			if($mid==null)
			{
				setguestparam();
			}
		}//else
		//{
			//$("#backlefticon").css("display","none");
		//}
	 
	$("#partName").html($groupname);
	$("#grouplogo").attr("src",$grouplogo);

  /*  var $headerHeight = $("header").height();
    var $footerHeight = $("footer").height();
    var $bannerHeight = $("#banner").height();
    var $yunzo_bg = $("body").height()-($headerHeight+$footerHeight+$bannerHeight);
*/
    
    $("#dync").attr("href","first_frame/dync_list.html");
	$("#groupinfo").attr("href","first_frame/groupinfo.html?gid="+$groupid);
    $("#eadd_list").attr("href","first_frame/cotacts_list.html");
    $("#inform").click(function(){
    	openNewFrame('first_frame/inform_list');
        });
    $("#commonadd_list").click(function(){
    	openNewFrame('first_frame/mycontacts_list');
   });
   /* $("#home").attr("href","main.html");
    $("#yunzo").attr("href","second_frame/yunzoquan.html");
    $("#myinfo").attr("href","third_frame/mine.html");*/
    getIsPushInfoFLag();
	getaAd();
});
function getIsPushInfoFLag()
{
	//.dyncyuandian,.infoyuandian,.frendyuandian,.busessyuandian
	var post={"mid":$mid,"did":"jpushinfoisreadflag","groupid":$groupid};
	ajaxcocRequest('../../api/yunzo/getMyReadNewInfoforFlag	','post',post,function(msg){
		if(msg.code==100){
			var thisItem = msg.datum;
			if(thisItem.n0!=0)
			{
				$(".dyncyuandian").css("display","block");
			}
			else{
				$(".dyncyuandian").css("display","none");
			}
			if(thisItem.n1!=0)
			{
				$(".infoyuandian").css("display","block");
			}
			else{
				$(".infoyuandian").css("display","none");
			}
			if(thisItem.n2!=0)
			{
				$(".frendyuandian").css("display","block");
			}
			else{
				$(".frendyuandian").css("display","none");
			}
			if(thisItem.n3!=0)
			{
				$(".busessyuandian").css("display","block");
			}
			else{
				$(".busessyuandian").css("display","none");
			}
			
		}
		
	});
	
}
//设置游客模式参数
function setguestparam()
{
	 var localData =  window.localStorage;
     localData.setItem("userNumber","13500000000");
	 localData.setItem(sysgroupid+"_"+"currentGroupid","88888888888888888888888888888888");
     localData.setItem(sysgroupid+"_"+"currentGroupName","云筑科技");
     localData.setItem(sysgroupid+"_"+"logoUrl","http://yunzo.oss.aliyuncs.com/cocmore_product/d041cac4-b1b9-4d48-8288-2a1cba2d244c.png");
	localData.setItem("looktype","guest");
	$("#partName").html($groupname);
	$("#grouplogo").attr("src",$grouplogo);
}
sTart_Stop();
//定制的图片轮播函数
function initSlide() {
	var bullets = document.getElementById('position').getElementsByTagName('li');
	var slider =
        Swipe(document.getElementById('slider'), {
            auto: 4000,
            continuous: true,
            disableScroll : true,
    		stopPropagation : true,
            callback: function(pos) {
                var i = bullets.length;
                while(i--){
                    bullets[i].className = ' ';
                }
                bullets[pos].className = 'on';
            }
        });
}
//获取投放广告
function getaAd() {
	var Post="mid="+$mid+"&groupid="+$groupid+"&adtype=1&did=00000";
	$.ajax({
		url:'../../api/getadimagebymidlist',
		type:'post',
		data:Post,
		success:function(msg){
			if(msg.code ==100){
				var len=msg.data.length;
				var html='';
				var htmll='';
				for(var i=0;i<len;i++){
					//html+='<figure><div class="face faceInner"><img src="'+msg.data[i].n2+'" width="100%" height="100%" /></div></figure>';
					html+="<figure><div class='face faceInner'><img src='"+msg.data[i].n2+"' width='100%' onclick=\"openpageparam('first_frame/adinfo.html','adid="+msg.data[i].n0+"')\" /></div></figure>";
					if(i==0){
						htmll+='<li class="no"></li>';
					}
					else{
						htmll+='<li class=""></li>'
					}
				}
				var swipeWrap=$(".swipe-wrap");
				var positions=$("#position");
				swipeWrap.append(html);
				positions.append(htmll);
				initSlide();
			}
			else{
				$("body").append('<div class="wuwang"><img src="../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')
			}
		}
	});
}


/*打开我的、云筑圈、我的*/
function openNewFrame(htmlName){
	if(htmlName=="first_frame/mycontacts_list")
	{
		if($mtype=="guest")
		{
			alert("游客模式无权限使用[好友]功能！");
		}else
		{
			window.location = htmlName+".html";
		}
	}else if(htmlName=="main")
	{
		if($mtype=="guest")
		{
			window.location = htmlName+".html?flag=guest";
		}else
		{
			window.location = htmlName+".html"+"?mid="+$mid+"&groupid="+$groupid;
		}
	}else if(htmlName=="third_frame/mine")
	{
		if($mtype=="guest")
		{
			if(confirm( '游客模式无权限使用[我的]功能！您现在是否要进入注册页面?'))
			{
				window.location="third_frame/enroll.html";
			}
			
		}else
		{
			window.location = htmlName+".html"+"?mid="+$mid+"&groupid="+$groupid;
		}
	}else if(htmlName=="first_frame/inform_list")
	{
		if($mtype=="guest")
		{
			alert("游客模式无权限使用[通知]功能！");
		}else
		{
			window.location = htmlName+".html";
		}
	}
	else
	{
		window.location = htmlName+".html"+"?mid="+$mid;
	}
		
}